package com.charity.mapper;

import com.charity.pojo.Admin;
import com.charity.pojo.Donation;
import com.charity.pojo.Entry;
import com.charity.pojo.User;
import org.apache.ibatis.annotations.*;
import org.fisco.bcos.sdk.abi.datatypes.Int;

import javax.swing.text.html.parser.Entity;
import java.util.List;


@Mapper
public interface AdminMapper {

    @Select("select * from admin where userName=#{userName} and password=#{password}")
    Admin admin(String userName, String password);

    @Insert("insert into admin(userName, password, realName, phone, email, createDate)" +
            "values(#{userName}, #{password}, #{realName}, #{phone}, #{email}, #{createDate})")
    Integer addAdmin(String userName, String password, String realName, String phone, String email, String createDate);

    @Select("select id from admin where userName=#{userName}")
    Long adminId(String userName);

    @Select("select * from admin where id=#{id}")
    Admin adminById(Long id);

    @Update("update admin set userName=#{userName}, password=#{password}, realName=#{realName}, phone=#{phone}, email=#{email} where id=#{id}")
    Integer updateAdmin(Long id, String userName, String password, String realName, String phone, String email);

    @Delete("delete from admin where id = #{id}")
    Integer deleteAdmin(Long id);

    @Select("select * from user")
    List<User> users();

    @Select("select * from admin")
    List<Admin> admins();

    @Select("select * from donation")
    List<Donation> donations() throws Exception;

    @Select("select * from entryd")
    List<Entry> entrys() throws Exception;

}
